package com.wsp.controllermanagement.controller;

import com.wsp.apimanagement.pojo.dto.Result;
import com.wsp.apimanagement.pojo.entity.Module;
import com.wsp.apimanagement.pojo.vo.ModuleRecord;
import com.wsp.apimanagement.pojo.vo.UserModule;
import com.wsp.apimanagement.service.ModuleService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Package: com.wsp.controllermanagement.controller
 * Description： TODO
 *
 * @Author: 巫思平
 * Copyright: Copyright (c) 2020
 * Version: 1
 */
@Api(tags = "模块管理接口")
@Validated
@RestController
@RequestMapping("/module")
public class ModuleController {
    @Autowired
    private ModuleService moduleService;

    /**
     * 查询所有模块
     */
    @GetMapping("/getModuleList")
    public Result<List<Module>> getModuleList(){
        return moduleService.getAllModule();
    }

    /**
     * 查询用户圈子
     */
    @GetMapping("/getUserModule/{userId}")
    public Result<List<UserModule>> getUserModule(@PathVariable("userId") @NotNull Long userId){
        return moduleService.getUserModule(userId);
    }

    /**
     * 拿到圈子打卡记录信息（每页4个）
     */
    @GetMapping("/getCircleInfo/{moduleId}/{currentPage}")
    public Result<ModuleRecord> getModuleRecord(
            @PathVariable("moduleId") @NotNull Long moduleId,
            @PathVariable("currentPage") @NotNull Integer currentPage
    ){
        return moduleService.getModuleRecord(moduleId, currentPage);
    }
}
